﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Telecom.Data;

namespace Telecom.Service
{
    public class loaiOdfService
    {
        private readonly EntitiesTelecom dbContext = new EntitiesTelecom();

        public loaiOdfService()
        {
            dbContext.Configuration.LazyLoadingEnabled = false;
            dbContext.Configuration.ProxyCreationEnabled = false;
        }

        public LOAI_ODF GetById(string Id)
        {
            try
            {
                return dbContext.LOAI_ODF.Where(p => p.MA == Id).First();
            }
            catch (Exception e)
            {
                LOAI_ODF _listRe = new LOAI_ODF();
                return _listRe;
            }
        }

        public List<LOAI_ODF> getList()
        {
            dbContext.Configuration.LazyLoadingEnabled = false;
            try
            {
                return dbContext.LOAI_ODF.OrderByDescending(p => p.MA).ToList();
            }
            catch (Exception e)
            {
                List<LOAI_ODF> _listRe = new List<LOAI_ODF>();
                return _listRe;
            }
        }
    }
}
